/**
 *  CSV Parser
 *  Luciano RUBIO <luciano@loociano.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "Date.hpp"

/**
 * Constructor
 */
Date::Date(string day)
{
	this->day = day;

	this->calories_allowed = 0;
	this->calories_consumed = 0;
	this->calories_burned = 0;
	this->calories_net = 0;

	this->sugars = 0;
	this->carbs = 0;
	this->fats = 0;
	this->protein = 0;
	this->cholesterol = 0;
	this->sodium = 0;
	this->fiber = 0;
}

/**
 * Destructor
 */
Date::~Date()
{

}

/**
 * Adds an item to the list
 */
void Date::addItem(Item item)
{
	items.push_back(item);
}

/**
 * Counts item by name
 */
int Date::countItem(const string& name)
{
	int count = 0;

	for (vector<Item>::iterator it = items.begin(); it != items.end(); ++it)
	{
		if (it->getName().find(toLowerCase(name)) != string::npos) count++;
	}
	return count;
}

double Date::countCaloriesIn(const string& name)
{
	double calIn = 0;

	for (vector<Item>::iterator it = items.begin(); it != items.end(); ++it)
	{
		if (it->getName().find(toLowerCase(name)) != string::npos)
		{
			calIn += it->getCaloriesIn();
		}
	}
	return calIn;
}

/**
 * Counts items
 */
size_t Date::countItems()
{
	return items.size();
}

// Getters

/**
 * returns the day
 */
string Date::getDay()
{
	return this->day;
}

/**
 * Returns calories allowed
 */
double Date::getCaloriesAllowed()
{
	return this->calories_allowed;
}

/**
 * Returns calories consumed
 */
double Date::getCaloriesConsumed()
{
	return this->calories_consumed;
}

/**
 * Returns calories burned
 */
double Date::getCaloriesBurned()
{
	return this->calories_burned;
}

/**
 * Returns calories net
 */
double Date::getCaloriesNet()
{
	return this->calories_net;
}

// Setters

/**
 * Sets the day
 */
void Date::setDay(string day)
{
	this->day = day;
}

/**
 * Sets calories allowed
 */
void Date::getCaloriesAllowed(double calories_allowed)
{
	this->calories_allowed = calories_allowed;
}

/**
 * Sets calories consumed
 */
void Date::getCaloriesConsumed(double calories_consumed)
{
	this->calories_consumed = calories_consumed;
}

/**
 * Sets calories burned
 */
void Date::getCaloriesBurned(double calories_burned)
{
	this->calories_burned = calories_burned;
}

/**
 * Sets calories net
 */
void Date::getCaloriesNet(double calories_net)
{
	this->calories_net = calories_net;
}
